﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Dynamics.BusinessConnectorNet;


namespace PJ.Data.Inventory
{
    public abstract class InventoryItemOrderParamAXProvider<TDataInterface> 
        : EntityAXProvider<TDataInterface>, IInventoryItemOrderParamProvider<TDataInterface>
        where TDataInterface : class, IInventoryItemOrderParamData
    {
        protected InventoryItemOrderParamAXProvider(IInventoryItemOrderParamCache<TDataInterface> cache)
            : base(cache)
        {

        }

        protected override void CopyFromContainer(AxaptaContainer container, TDataInterface data)
        {
            base.CopyFromContainer(container, data);
            if (container.Count < 7)
                throw new ArgumentOutOfRangeException("container", container.Count, "should have at least 7 items");
            data.UnitId = ((string)container.get_Item(4)).Trim();
            data.DefaultQuantity = (double)container.get_Item(5);
            data.MinQuantity = (double)container.get_Item(6);
            data.MaxQuantity = (double)container.get_Item(7);
        }

    }
}
